<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="/vue-study/study2/lib/vue-2.6.12.js"></script>
    <title>4深度侦听</title>
  </head>
  <body>
    <div id="app">
      <input type="text" v-model="info.username" /><hr>
      <input type="text" v-model="info.area.city" />

    </div>
    <script>
      const vm = new Vue({
        el: "#app",
        data() {
          return {
            // 用户的信息对象
            info: {
              username: "dongdong ",
              area:{
                city:"兴化"
              }
            },
          };
        },
        methods: {},
        filters: {},
        watch: {
            // 监听对象的子属性
          'info.area.city'(newVal){
            console.log(newVal);
          },

          //监听整个对象
          info: {
            handler(newVal) {
              console.log(newVal);
            },
            // 开启深度监听
            deep: true,
          },
        },
      });
    </script>
  </body>
</html>
